$(document).ready(function () {
    'use strict'
    // banner 分页器
    let mySwiper = new Swiper('#banner-swiper', {
        loop: true,
        speed: 2000,
        autoplay: {
            delay: 1000,
            stopOnLastSlide: false,
            disableOnInteraction: false,
        },
        // 如果需要分页器
        pagination: {
            el: '#banner-swiper .swiper-pagination',
            clickable: true,
            renderBullet: function (index, className) {
                return '<span class="' + className + '">' + '0' + (index + 1) + '</span>'
            },
        },
    })
    setNewsHeight()
    i18n1()
})
$(window).resize(setNewsHeight)

// 主体新闻自适应高度
function setNewsHeight() {
    let section = $("#section")
    let imageBox = section.find('.news-image')
    let newsBox = imageBox.siblings('.news-article')
    newsBox.css("box-sizing", "border-box").height(imageBox.height())
    if ($(document).width() < 550) {
        newsBox.height('auto').css("margin", "20px 0")
    }
}

function i18n1() {
    i18n.init({
        resGetPath: 'i18n/__lng__/__ns__.json',
        lng: 'zh_CN',
        fallbackLng: 'zh_CN'
    }, function (t) {
        $('body').i18n()
    })

    $('#language').on("click", "a", function () {
        i18n.init({
            resGetPath: 'i18n/__lng__/__ns__.json',
            lng: $(this).attr('data-val'),
            fallbackLng: 'zh_CN'
        }, function (t) {
            $('body').i18n()
        })
    })
}